package com.uls.web.controller.lh;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.uls.lh.domain.LhCarinfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uls.common.annotation.Log;
import com.uls.common.core.controller.BaseController;
import com.uls.common.core.domain.AjaxResult;
import com.uls.common.enums.BusinessType;
import com.uls.lh.domain.LhDriverinfo;
import com.uls.lh.service.ILhDriverinfoService;
import com.uls.common.utils.poi.ExcelUtil;
import com.uls.common.core.page.TableDataInfo;

/**
 * 驾驶员信息管理Controller
 * 
 * @author lh
 * @date 2024-11-07
 */
@RestController
@RequestMapping("/lh/driverinfo")
public class LhDriverinfoController extends BaseController
{
    @Autowired
    private ILhDriverinfoService lhDriverinfoService;

    /**
     * 查询驾驶员信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('lh:driverinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhDriverinfo lhDriverinfo)
    {
        startPage();
        List<LhDriverinfo> list = lhDriverinfoService.selectLhDriverinfoList(lhDriverinfo);
        return getDataTable(list);
    }

    /**
     * 导出驾驶员信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('lh:driverinfo:export')")
    @Log(title = "驾驶员信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhDriverinfo lhDriverinfo)
    {
        List<LhDriverinfo> list = lhDriverinfoService.selectLhDriverinfoList(lhDriverinfo);
        ExcelUtil<LhDriverinfo> util = new ExcelUtil<LhDriverinfo>(LhDriverinfo.class);
        util.exportExcel(response, list, "驾驶员信息管理数据");
    }

    /**
     * 获取驾驶员信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('lh:driverinfo:query')")
    @GetMapping(value = "/{driverId}")
    public AjaxResult getInfo(@PathVariable("driverId") Long driverId)
    {
        return success(lhDriverinfoService.selectLhDriverinfoByDriverId(driverId));
    }


    /**
     * 获取所有车辆信息
     * @return
     */
    @GetMapping("/getAlldriverbystatus")
    public AjaxResult getAlldriverbystatus()
    {
        List<LhDriverinfo> list = lhDriverinfoService.selectLhDriverinfoBystatus("1");
        return success(list);
    }

    /**
     * 新增驾驶员信息管理
     */
    @PreAuthorize("@ss.hasPermi('lh:driverinfo:add')")
    @Log(title = "驾驶员信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhDriverinfo lhDriverinfo)
    {
        return toAjax(lhDriverinfoService.insertLhDriverinfo(lhDriverinfo));
    }

    /**
     * 修改驾驶员信息管理
     */
    @PreAuthorize("@ss.hasPermi('lh:driverinfo:edit')")
    @Log(title = "驾驶员信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhDriverinfo lhDriverinfo)
    {
        return toAjax(lhDriverinfoService.updateLhDriverinfo(lhDriverinfo));
    }

    /**
     * 删除驾驶员信息管理
     */
    @PreAuthorize("@ss.hasPermi('lh:driverinfo:remove')")
    @Log(title = "驾驶员信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{driverIds}")
    public AjaxResult remove(@PathVariable Long[] driverIds)
    {
        return toAjax(lhDriverinfoService.deleteLhDriverinfoByDriverIds(driverIds));
    }



}
